ALTER procedure [dbo].[USP_IVR_SAVE_OnlineRegistrationSlip]
@REQDATE datetime,
@USERNAME varchar(150),
@REMARKS varchar(150),
@LEASEDTYPE varchar(50)
as
--BEGIN
	--BEGIN TRY
		--BEGIN TRANSACTION
			--AUTOGENRATED SLIP NO FROM THE DATABASE
			DECLARE @SLIPNO INT;
			SET @SLIPNO=(select CONVERT(varchar,CONVERT(int, SUBSTRING(CONVERT(varchar, ISNULL(MAX(Slipno),0)),-3,LEN(CONVERT(varchar,ISNULL(MAX(Slipno),0)))))+1)+'1415' as SlipNo from IVR_OnlineRegistrationSlip)			
			--print @slipno
			--INSERTING THE DATA INTO THE TABLE WITH SLIPNO
			INSERT INTO IVR_OnlineRegistrationSlip (reqdate,slipno,username,remarks,cdate,Leasedtype) VALUES (@REQDATE,@SLIPNO,@USERNAME,@REMARKS,GETDATE(),@LEASEDTYPE)			
		--COMMIT TRANSACTION
		--FOR GET THE SLIPNO
			SELECT MAX(SLIPNO)as SLIPNO FROM IVR_OnlineRegistrationSlip
	--END TRY
	--BEGIN CATCH
		--IF @@TRANCOUNT>0
			--ROLLBACK TRANSACTION
	--END CATCH
--END




ALTER procedure [dbo].[USP_IVR_SAVE_OnlineRegistration_Detail]
@ItemCode varchar(50),
@ItemDesc varchar(50),
@Requestqty varchar(50),
@PeCode varchar(50),
@ProductDesc varchar(50),
@ProductModel varchar(50),
@Ro varchar(50),
@Customer varchar(50),
@Project varchar(50),
@TITID varchar(150)=NULL,
@ITEM_ItemID int=null,
@ITEM_ItemQty varchar(50)=Null,
@ITEM_Rate decimal(18,2)=null,
@Leasedtype varchar(50)=null,
@OpQuantity decimal(18,2)=Null,
@OpSlnum int=Null,
@cname varchar(100)=Null
as
BEGIN
BEGIN TRY
	BEGIN TRANSACTION
		declare @regid int;
		set @regid=(select IDENT_CURRENT('IVR_onlineRegistrationSlip'))
		INSERT INTO IVR_OnlineRegistration_Detail (regid,itemcode,itemdesc,pecode,productdesc,productmodel,ro,
		customer,project,cdate,Requestqty,ITEM_TITID,ITEM_ITEMID,ITEM_ItemQTY,ITEM_Rate,LeasedType,OPQuantity,OPslnum,cname) 
		VALUES(@regid,@ItemCode,@ItemDesc,@PeCode,@ProductDesc,@ProductModel,@Ro,@Customer,@Project,GETDATE(),
		@Requestqty,@TITID,@ITEM_ItemID,@ITEM_ItemQty,@ITEM_Rate,@Leasedtype,@OpQuantity,@OpSlnum,@cname)
	COMMIT TRAN
END TRY
BEGIN CATCH
	if @@TRANCOUNT>0
		ROLLBACK TRAN
END CATCH
End